package com.itheima.mapper;

import com.github.pagehelper.Page;
import com.itheima.pojo.CheckItem;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CheckitemMapper {
    /**
     * 根据查询条件查询
     * @param queryString
     * @return
     */

    Page<CheckItem> getByQueryString(String queryString);

    /**
     * 新增检查项
     * @param checkItem
     */
    @Insert("insert into t_checkitem (code, name, sex, age, price, type, attention, remark) VALUES " +
            "(#{code}, #{name}, #{sex}, #{age}, #{price}, #{type}, #{attention}, #{remark})")
    void add(CheckItem checkItem);

    /**
     * 根据id删除检查项
     * @param id
     */
    @Delete("delete from t_checkitem where id = #{id}")
    void deleteById(Integer id);

    /**
     * 根据id查询检查项
     * @param id
     * @return
     */
    @Select("select * from t_checkitem where id = #{id}")
    CheckItem findById(Integer id);

    /**
     * 编辑检查项
     * @param checkItem
     */
    void edit(CheckItem checkItem);

    /**
     * 查询所有检查项
     * @return
     */
    @Select("select * from t_checkitem")
    List<CheckItem> findAll();

}
